package com.shujia.tf

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.streaming.api.scala._

object Demo1Map {

  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    //基于集合构建DS，有界流
    val ds: DataStream[Int] = env.fromCollection(List(1,2,3,4,5,6,7,8))

    //scala语言的方式
    val ds1: DataStream[Int] = ds.map(i => i*2)

    //java的方式
    val ds2: DataStream[Int] = ds.map(new MapFunction[Int,Int] {
      override def map(value: Int): Int = {
        value*2
      }
    })

    ds2.print()

    env.execute()

  }

}
